<?php
/**
 * OpenSSL用の公開鍵・秘密鍵の作成
 *
 * Copyright:2005/09/03, Adrian at http://jp2.php.net/manual/en/function.openssl-public-encrypt.php
 */
if(!function_exists('ssl_create_pairkey')){
    function ssl_create_pairkey($sPassword){

        $rPrivateKey = openssl_pkey_new();

        $bResult = openssl_pkey_export($rPrivateKey, $sPrivateKey, $sPassword);

        if($bResult){
            $aPublicKey = openssl_pkey_get_details($rPrivateKey);

            $aResponce = array(
                'PRIVATE_KEY' => $sPrivateKey,
                'PUBLIC_KEY'  => $aPublicKey['key'],
            );

            return $aResponce;
        }
    }
}

?>